﻿using Dm;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class index3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                if (Cache["key"] == null)
                {
                    string strconn = "server=10.2.0.36;database=旧襄阳市市本级;User Id=SYSDBA;PWD=SYSDBA";
                    //DmConnection conn = new DmConnection(strconn);
                    string sql = "select  top  100 * from 旧襄阳市市本级.分析表_近三年税款征收数据表 a,旧襄阳市市本级.代码表_行政区划 b where a.地区代码=b.地区代码 and b.地区代码='420601'";
                    DmDataAdapter oda = new DmDataAdapter(sql, strconn);
                    DataTable dt = new DataTable();
                    Cache.Insert("key", dt, null, DateTime.Now.AddSeconds(100), System.Web.Caching.Cache.NoSlidingExpiration);
                    oda.Fill(dt);
                    dt.Dispose();
                    oda.Dispose();
                    this.GridView1.DataSource = dt;
                    this.GridView1.DataBind();
                }
            else
            {
                this.GridView1.DataSource = Cache["key"];
                this.GridView1.DataBind();

            }
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
            {
                //保持列不变形 
                for (int i = 0; i < e.Row.Cells.Count; i++)
                {
                    //方法一： 
                    e.Row.Cells[i].Text = " " + e.Row.Cells[i].Text + " ";
                    e.Row.Cells[i].Wrap = false;
                    //方法二： 
                    //e.Row.Cells[i].Text = "<nobr> " + e.Row.Cells[i].Text + " </nobr>"; 
                }
            }
        }
    }
}

